package com.example.ui_design;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.LifecycleOwner;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

import component.BookItemComponent;

public class  MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }

  @Override
  protected void onResume() {
    super.onResume();
    View itemView = getLayoutInflater().inflate(R.layout.item_view, null);
    //创建component
    BookItemComponent bookItemComponent = new BookItemComponent(itemView, getViewModelStore(), this);
    // 绑定生命周期
    bookItemComponent.bind(this);

    // 父Container添加View
    ViewGroup container = findViewById(R.id.sub_container);
    container.addView(itemView);
  }
}